package com.uuah.server.config.spring.parsers.specific;

import org.springframework.beans.factory.BeanDefinitionStoreException;
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.xml.ParserContext;
import org.w3c.dom.Element;

import com.uuah.server.api.config.IUuahConfiguration;
import com.uuah.server.config.Constants;
import com.uuah.server.config.spring.parsers.generic.NamedDefinitionParser;

/**
 * Parses the <uuah:configuration> element. If this element appears in multiple
 * Xml config files each will its configuration to a single
 * {@link IUuahConfiguration} object.
 *
 * @see IUuahConfiguration
 */
public class ConfigurationDefinitionParser extends NamedDefinitionParser {
	public ConfigurationDefinitionParser() {
		super(Constants.OBJECT_UUAH_CONFIGURATION);
		singleton = true;
	}

	protected Class getBeanClass(Element element) {
		return IUuahConfiguration.class;
	}

	// @Override
	protected String resolveId(Element element,
			AbstractBeanDefinition definition, ParserContext parserContext)
			throws BeanDefinitionStoreException {
		return Constants.OBJECT_UUAH_CONFIGURATION;
	}

}